#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int Maxn=1e6+5,mod=1e9+7;
inline int ksm(int a,int k){
	int res=1;
	for(;k;k>>=1,a=a*a%mod)if(k&1)res=res*a%mod;
	return res;
}
int n,k,a[Maxn],b[Maxn],fa[Maxn],ans;
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int f[Maxn],vis[Maxn],cntt;
void dfs(int x){
	if(x==k+1){
		for(int i=1;i<=n;i++)b[i]=a[i],fa[i]=i;
		for(int i=1;i<=k;i++){
			b[find(f[i])]+=mod-b[f[i]+1];
			b[find(f[i])]%=mod;
			fa[f[i]+1]=find(f[i]);
		}for(int i=1;i<=n;i++)if(!vis[i-1])ans=(ans+b[i])%mod;
		++cntt;
		return;
	}
	for(int i=1;i<n;i++)
		if(!vis[i])vis[i]=1,f[x]=i,dfs(x+1),vis[i]=0;
}
namespace liuliuliu{
	int fac[Maxn],inv[Maxn];
	inline int C(int n,int m){
		return fac[n]*inv[n-m]%mod*inv[m]%mod;
	}
	inline int A(int n,int m){
		return fac[n]*inv[n-m]%mod;
	}
	void dfs1(int x,int K,int pp){
		if(x==K+1){
			for(int i=1;i<=4;i++)b[i]=a[i],fa[i]=i;
			for(int i=1;i<=K;i++){
				b[find(f[i])]+=mod-b[f[i]+1];
				b[find(f[i])]%=mod;
				fa[f[i]+1]=find(f[i]);
			}for(int i=1;i<=3;i++)if(!vis[i-1])ans=(ans+b[i]*pp%mod)%mod;
			cntt=(cntt+pp)%mod;
			return;
		}
		for(int i=1;i<=3;i++)
			if(!vis[i])vis[i]=1,f[x]=i,dfs1(x+1,K,pp),vis[i]=0;
	}
	inline void solve(){
		fac[0]=1;for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
		inv[n]=ksm(fac[n],mod-2);
		for(int i=n;i;i--)inv[i-1]=inv[i]*i%mod;
		for(int i=0;i<=min(k,3ll);i++)dfs1(1,i,C(k,i)*A(n-4,k-i)%mod);
		printf("%lld\n",ans*ksm(cntt,mod-2)%mod);
	}
}
signed main(){
	freopen("game.in","r",stdin);
	freopen("game.out","w",stdout);
	n=read();k=read();
	for(int i=1;i<=n;i++)a[i]=read();
	if(n<=10){
		dfs(1);printf("%lld\n",ans*ksm(cntt,mod-2)%mod);
		cerr<<ans<<"/"<<cntt<<'\n';
		return 0;
	}
	for(int i=4;i<=n;i++)a[3]=(a[3]+a[i])%mod,a[i]=0;
	liuliuliu::solve();
	return 0;
}
/*
3 1
1 2 3
ans:1

3 2
1 2 3
ans:-1

4 1
1 2 3 4
ans:4

4 2
1 2 3 4
ans:1/3

4 3
1 2 3 4
ans:-1

5 1
1 2 3 4 5
ans:8

5 2
1 2 3 4 5
ans:3

5 3
1 2 3 4 5
ans:0

5 4
1 2 3 4 5
ans:-1

6 1
1 2 3 4 5 6
ans:13

6 2
1 2 3 4 5 6
ans:34/5

6 3
1 2 3 4 5 6
ans:12/5

6 4
1 2 3 4 5 6
ans:-1/5

6 5
1 2 3 4 5 6
ans:-1

7 1
1 2 3 4 5 6 7
ans:19

7 2
1 2 3 4 5 6 7
ans:35/3

7 3
1 2 3 4 5 6 7
ans:6

7 4
1 2 3 4 5 6 7
ans:2

7 5
1 2 3 4 5 6 7
ans:-1/3 

7 6
1 2 3 4 5 6 7
ans:-1

8 1
1 2 3 4 5 6 7 8
ans:26

8 2
1 2 3 4 5 6 7 8
ans:123/7

8 3
1 2 3 4 5 6 7 8
ans:75/7

8 4
1 2 3 4 5 6 7 8
ans:38/7

8 5
1 2 3 4 5 6 7 8
ans:12/7

8 6
1 2 3 4 5 6 7 8
ans:-3/7

8 7
1 2 3 4 5 6 7 8
ans:-1

7 6
1 5 900000 1003 107 201 2005

7 5
1 5 9000 1003 107 201 2005
ans:-14/6

8 5
1 2 3 4 5 6 7 8

8 4
1 2 33 0 0 0 0 0

8 5
1 2 3 4 5 6 7 9
*/
